home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / ixemul / sdk / man / cat4 / tty.0 < prev    next >
Encoding:
Text File  |  1998-06-15  |  14.0 KB  |  261 lines

  1.  
  2. TTY(4)                     UNIX Programmer's Manual                     TTY(4)
  3.  
  4. NNAAMMEE
  5.      ttttyy - general terminal interface
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ssyyss//iiooccttll..hh>>
  9.  
  10. DDEESSCCRRIIPPTTIIOONN
  11.      This section describes the interface to the terminal drivers in the sys-
  12.      tem.
  13.  
  14.    TTeerrmmiinnaall SSppeecciiaall FFiilleess
  15.      Each hardware terminal port on the system usually has a terminal special
  16.      device file associated with it in the directory ``/dev/'' (for example,
  17.      ``/dev/tty03'').  When a user logs into the system on one of these hard-
  18.      ware terminal ports, the system has already opened the associated device
  19.      and prepared the line for normal interactive use (see getty(8).)  There
  20.      is also a special case of a terminal file that connects not to a hardware
  21.      terminal port, but to another program on the other side.  These special
  22.      terminal devices are called _p_t_y_s and provide the mechanism necessary to
  23.      give users the same interface to the system when logging in over a net-
  24.      work (using rlogin(1),  or telnet(1) for example.)  Even in these cases
  25.      the details of how the terminal file was opened and set up is already
  26.      handled by special software in the system.  Thus, users do not normally
  27.      need to worry about the details of how these lines are opened or used.
  28.      Also, these lines are often used for dialing out of a system (through an
  29.      out-calling modem), but again the system provides programs that hide the
  30.      details of accessing these terminal special files (see tip(2).)
  31.  
  32.      When an interactive user logs in, the system prepares the line to behave
  33.      in a certain way (called a _l_i_n_e _d_i_s_c_i_p_l_i_n_e), the particular details of
  34.      which is described in stty(1) at the command level, and in termios(4) at
  35.      the programming level.  A user may be concerned with changing settings
  36.      associated with his particular login terminal and should refer to the
  37.      preceding man pages for the common cases.  The remainder of this man page
  38.      is concerned with describing details of using and controlling terminal
  39.      devices at a low level, such as that possibly required by a program wish-
  40.      ing to provide features similar to those provided by the system.
  41.  
  42.    LLiinnee ddiisscciipplliinneess
  43.      A terminal file is used like any other file in the system in that it can
  44.      be opened, read, and written to using standard system calls.  For each
  45.      existing terminal file, there is a software processing module called a
  46.      _l_i_n_e _d_i_s_c_i_p_l_i_n_e is associated with it.  The _l_i_n_e _d_i_s_c_i_p_l_i_n_e essentially
  47.      glues the low level device driver code with the high level generic inter-
  48.      face routines (such as read(2) and write(2)),  and is responsible for im-
  49.      plementing the semantics associated with the device.  When a terminal
  50.      file is first opened by a program, the default _l_i_n_e _d_i_s_c_i_p_l_i_n_e called the
  51.      termios line discipline is associated with the file.  This is the primary
  52.      line discipline that is used in most cases and provides the semantics
  53.      that users normally associate with a terminal.  When the termios line
  54.      discipline is in effect, the terminal file behaves and is operated ac-
  55.      cording to the rules described in termios(4).  Please refer to that man
  56.      page for a full description of the terminal semantics.  The operations
  57.      described here generally represent features common across all _l_i_n_e
  58.      _d_i_s_c_i_p_l_i_n_e_s, however some of these calls may not make sense in conjunc-
  59.      tion with a line discipline other than termios, and some may not be sup-
  60.      ported by the underlying hardware (or lack thereof, as in the case of
  61.      ptys).
  62.  
  63.    TTeerrmmiinnaall FFiillee OOppeerraattiioonnss
  64.      All of the following operations are invoked using the ioctl(2) system
  65.      call.  Refer to that man page for a description of the _r_e_q_u_e_s_t and _a_r_g_p
  66.      parameters.  In addition to the ioctl _r_e_q_u_e_s_t_s defined here, the specific
  67.      line discipline in effect will define other _r_e_q_u_e_s_t_s specific to it (ac-
  68.      tually termios(4) defines them as function calls, not ioctl _r_e_q_u_e_s_t_s.)
  69.      The following section lists the available ioctl requests.  The name of
  70.      the request, a description of its purpose, and the typed _a_r_g_p parameter
  71.      (if any) are listed.  For example, the first entry says
  72.  
  73.            _T_I_O_C_S_E_T_D _i_n_t _*_l_d_i_s_c
  74.  
  75.      and would be called on the terminal associated with file descriptor zero
  76.      by the following code fragment:
  77.  
  78.              int ldisc;
  79.  
  80.              ldisc = TTYDISC;
  81.              ioctl(0, TIOCSETD, &ldisc);
  82.  
  83.    TTeerrmmiinnaall FFiillee RReeqquueesstt DDeessccrriippttiioonnss
  84.  
  85.      TIOCSETD _i_n_t _*_l_d_i_s_c
  86.                  Change to the new line discipline pointed to by _l_d_i_s_c. The
  87.                  available line disciplines are listed in <sys/termios.h> and
  88.                  currently are:
  89.  
  90.                  TTYDISC     Termios interactive line discipline.
  91.                  TABLDISC    Tablet line discipline.
  92.                  SLIPDISC    Serial IP line discipline.
  93.  
  94.      TIOCGETD _i_n_t _*_l_d_i_s_c
  95.                  Return the current line discipline in the integer pointed to
  96.                  by _l_d_i_s_c.
  97.  
  98.      TIOCSBRK _v_o_i_d
  99.                  Set the terminal hardware into BREAK condition.
  100.  
  101.      TIOCCBRK _v_o_i_d
  102.                  Clear the terminal hardware BREAK condition.
  103.  
  104.      TIOCSDTR _v_o_i_d
  105.                  Assert data terminal ready (DTR).
  106.  
  107.      TIOCCDTR _v_o_i_d
  108.                  Clear data terminal ready (DTR).
  109.  
  110.      TIOCGPGRP _i_n_t _*_t_p_g_r_p
  111.                  Return the current process group the terminal is associated
  112.                  with in the integer pointed to by _t_p_g_r_p. This is the underly-
  113.                  ing call that implements the termios(4) ttccggeettaattttrr() call.
  114.  
  115.      TIOCSPGRP _i_n_t _*_t_p_g_r_p
  116.                  Associate the terminal with the process group (as an integer)
  117.                  pointed to by _t_p_g_r_p. This is the underlying call that imple-
  118.                  ments the termios(4) ttccsseettaattttrr() call.
  119.  
  120.      TIOCGETA _s_t_r_u_c_t _t_e_r_m_i_o_s _*_t_e_r_m
  121.                  Place the current value of the termios state associated with
  122.                  the device in the termios structure pointed to by _t_e_r_m. This
  123.                  is the underlying call that implements the termios(4)
  124.                  ttccggeettaattttrr() call.
  125.  
  126.      TIOCSETA _s_t_r_u_c_t _t_e_r_m_i_o_s _*_t_e_r_m
  127.                  Set the termios state associated with the device immediately.
  128.                  This is the underlying call that implements the termios(4)
  129.                  ttccsseettaattttrr() call with the TCSANOW option.
  130.  
  131.      TIOCSETAW _s_t_r_u_c_t _t_e_r_m_i_o_s _*_t_e_r_m
  132.                  First wait for any output to complete, then set the termios
  133.                  state associated with the device.  This is the underlying
  134.                  call that implements the termios(4) ttccsseettaattttrr() call with the
  135.                  TCSADRAIN option.
  136.  
  137.      TIOCSETAF _s_t_r_u_c_t _t_e_r_m_i_o_s _*_t_e_r_m
  138.                  First wait for any output to complete, clear any pending in-
  139.                  put, then set the termios state associated with the device.
  140.                  This is the underlying call that implements the termios(4)
  141.                  ttccsseettaattttrr() call with the TCSAFLUSH option.
  142.  
  143.      TIOCOUTQ _i_n_t _*_n_u_m
  144.                  Place the current number of characters in the output queue in
  145.                  the integer pointed to by _n_u_m.
  146.  
  147.      TIOCSTI _c_h_a_r _*_c_p
  148.                  Simulate typed input.  Pretend as if the terminal received
  149.                  the character pointed to by _c_p.
  150.  
  151.      TIOCNOTTY _v_o_i_d
  152.                  This call is obsolete but left for compatibility.  In the
  153.                  past, when a process that didn't have a controlling terminal
  154.                  (see _T_h_e _C_o_n_t_r_o_l_l_i_n_g _T_e_r_m_i_n_a_l in termios(4))  first opened a
  155.                  terminal device, it acquired that terminal as its controlling
  156.                  terminal.  For some programs this was a hazard as they didn't
  157.                  want a controlling terminal in the first place, and this pro-
  158.                  vided a mechanism to disassociate the controlling terminal
  159.                  from the calling process.  It _m_u_s_t be called by opening the
  160.                  file _/_d_e_v_/_t_t_y and calling TIOCNOTTY on that file descriptor.
  161.  
  162.                  The current system does not allocate a controlling terminal
  163.                  to a process on an ooppeenn() call: there is a specific ioctl
  164.                  called TIOSCTTY to make a terminal the controlling terminal.
  165.                  In addition, a program can ffoorrkk() and call the sseettssiidd() sys-
  166.                  tem call which will place the process into its own session -
  167.                  which has the effect of disassociating it from the control-
  168.                  ling terminal.  This is the new and preferred method for pro-
  169.                  grams to lose their controlling terminal.
  170.  
  171.      TIOCSTOP _v_o_i_d
  172.                  Stop output on the terminal (like typing ^S at the keyboard).
  173.  
  174.      TIOCSTART _v_o_i_d
  175.                  Start output on the terminal (like typing ^Q at the key-
  176.                  board).
  177.  
  178.      TIOCSCTTY _v_o_i_d
  179.                  Make the terminal the controlling terminal for the process
  180.                  (the process must not currently have a controlling terminal).
  181.  
  182.      TIOCDRAIN _v_o_i_d
  183.                  Wait until all output is drained.
  184.  
  185.      TIOCEXCL _v_o_i_d
  186.                  Set exclusive use on the terminal.  No further opens are per-
  187.                  mitted except by root.  Of course, this means that programs
  188.                  that are run by root (or setuid) will not obey the exclusive
  189.                  setting - which limits the usefulness of this feature.
  190.  
  191.      TIOCNXCL _v_o_i_d
  192.                  Clear exclusive use of the terminal.  Further opens are per-
  193.                  mitted.
  194.  
  195.      TIOCFLUSH _i_n_t _*_w_h_a_t
  196.                  If the value of the int pointed to by _w_h_a_t contains the FREAD
  197.                  bit as defined in <sys/file.h>, then all characters in the
  198.                  input queue are cleared.  If it contains the FWRITE bit, then
  199.                  all characters in the output queue are cleared.  If the value
  200.                  of the integer is zero, then it behaves as if both the FREAD
  201.                  and FWRITE bits were set (i.e. clears both queues).
  202.  
  203.      TIOCGWINSZ _s_t_r_u_c_t _w_i_n_s_i_z_e _*_w_s
  204.                  Put the window size information associated with the terminal
  205.                  in the _w_i_n_s_i_z_e structure pointed to by _w_s. The window size
  206.                  structure contains the number of rows and columns (and pixels
  207.                  if appropriate) of the devices attached to the terminal.  It
  208.                  is set by user software and is the means by which most full-
  209.                  screen oriented programs determine the screen size.  The
  210.                  _w_i_n_s_i_z_e structure is defined in <sys/ioctl.h>.
  211.  
  212.      TIOCSWINSZ _s_t_r_u_c_t _w_i_n_s_i_z_e _*_w_s
  213.                  Set the window size associated with the terminal to be the
  214.                  value in the _w_i_n_s_i_z_e structure pointed to by _w_s (see above).
  215.  
  216.      TIOCCONS _i_n_t _*_o_n
  217.                  If _o_n points to a non-zero integer, redirect kernel console
  218.                  output (kernel printf's) to this terminal.  If _o_n points to a
  219.                  zero integer, redirect kernel console output back to the nor-
  220.                  mal console.  This is usually used on workstations to redi-
  221.                  rect kernel messages to a particular window.
  222.  
  223.      TIOCMSET _i_n_t _*_s_t_a_t_e
  224.                  The integer pointed to by _s_t_a_t_e contains bits that correspond
  225.                  to modem state.  Following is a list of defined variables and
  226.                  the modem state they represent:
  227.  
  228.                  TIOCM_LE   Line Enable.
  229.                  TIOCM_DTR  Data Terminal Ready.
  230.                  TIOCM_RTS  Request To Send.
  231.                  TIOCM_ST   Secondary Transmit.
  232.                  TIOCM_SR   Secondary Receive.
  233.                  TIOCM_CTS  Clear To Send.
  234.                  TIOCM_CAR  Carrier Detect.
  235.                  TIOCM_CD   Carier Detect (synonym).
  236.                  TIOCM_RNG  Ring Indication.
  237.                  TIOCM_RI   Ring Indication (synonym).
  238.                  TIOCM_DSR  Data Set Ready.
  239.  
  240.                  This call sets the terminal modem state to that represented
  241.                  by _s_t_a_t_e. Not all terminals may support this.
  242.  
  243.      TIOCMGET _i_n_t _*_s_t_a_t_e
  244.                  Return the current state of the terminal modem lines as rep-
  245.                  resented above in the integer pointed to by _s_t_a_t_e.
  246.  
  247.      TIOCMBIS _i_n_t _*_s_t_a_t_e
  248.                  The bits in the integer pointed to by _s_t_a_t_e represent modem
  249.                  state as described above, however the state is OR-ed in with
  250.                  the current state.
  251.  
  252.      TIOCMBIC _i_n_t _*_s_t_a_t_e
  253.                  The bits in the integer pointed to by _s_t_a_t_e represent modem
  254.                  state as described above, however each bit which is on in
  255.                  _s_t_a_t_e is cleared in the terminal.
  256.  
  257. SSEEEE AALLSSOO
  258.      getty(8),  ioctl(2),  pty(4),  stty(1),  termios(4)
  259.  
  260. 4th Berkeley Distribution       August 14, 1992                              4
  261.